home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / ISR.SWG / 0002_DELAYHK.PAS.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  1KB  |  43 lines

  1. {
  2. REYNIR STEFANSSON
  3.  
  4. > I need a Procedure in the form of:
  5. > Type DelayHook = Function : Boolean;
  6. > Procedure DelayIt(S : Word; Hook : DelayHook);
  7.  
  8. > What it needs to do is keep calling the hook Function Until it returns
  9. > True or the number of 1/100th's of seconds, S, is up.
  10.  
  11. > Any ideas?  I know how to call the Hook Function, but I am concerned With
  12. > how to go about keeping up With the time Without using the Crt.Delay
  13. > Procedure. I am using this to play a tune (with Sound and NoSound) through
  14. > the speaker and quit when the user presses a key.  The tune is read from
  15. > a Text File of unknown length.  HELP!
  16.  
  17. { More or less outta my head... }
  18.  
  19. Uses
  20.   Dos;
  21.  
  22. Type
  23.   Reg       : Registers;
  24.   DelayHook : Function : Boolean;
  25.  
  26. {
  27.    This proc Uses the AT BIOS' Wait Function: INT 15h, FUNC 86h. It's
  28.    called With a LongInt in CX:DX. Its resolution is ca. 1 microsecond.
  29. }
  30.  
  31. Procedure DelayIt(S : Word; Hook : DelayHook);
  32. Var
  33.   dly : LongInt;
  34.   bdy : Boolean;
  35. begin
  36.   Repeat
  37.     Reg.AH := $86;
  38.     Reg.CX := 0;
  39.     Reg.DX := 10000; { Wait 0.01 sec. }
  40.     Intr($15, Reg);
  41.   Until Hook;
  42. end;
  43.